package com.dexgdx.game.structure;

import com.badlogic.gdx.math.Rectangle;

public class Region extends Rectangle{
	
	private static final long serialVersionUID = 7222567625350253896L;

	protected boolean solidRegion;
	
	public Region() {
		super();
		initialize();
	}
	
	public Region(float x, float y, float height, float width) {
		super(x, y, width, height);
		initialize();
	}
	
	private void initialize(){
		solidRegion = false;
	}

	public float getMidX() {
		return x + width/2;
	}
	
	public float getMidY() {
		return y + height/2;
	}

	public void setFromMidX(int x) {
		this.x = x - width/2;
	}
	
	public void setFromMidY(int y) {
		this.y = y - height/2;
	}
	
	public boolean isSolidRegion() {
		return solidRegion;
	}
	public Region setMiddleToCornerRegion(){
		x = x - width / 2;
		y = y - height / 2;
		return this;
	}
	
	public boolean isStepCloseTo(Region region){
		return Math.abs(x - region.x) < 10 && Math.abs(y - region.y) < 10;
	}
	
	public static Region fromXYAndRegion(int x, int y, Region region){
		Region newRegion = new Region(x, y, region.getHeight(), region.getWidth());
		newRegion.setFromMidX(x);
		newRegion.setFromMidY(y);
		return newRegion;
	}
	
}
